<%@ page import="org.codehaus.groovy.grails.plugins.springsecurity.AuthorizeTools" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title><g:message code="job.nav.show"/></title>
</head>
<body>
<div class="nav">
    <span class="menuButton"><g:link class="list" action="list"><g:message code="job.nav.list"/></g:link></span>
</div>
<div class="body">
    <h1><g:message code="job.nav.show"/></h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <div class="dialog">
        <table>
            <tbody>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.id"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'id')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.actual.value"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'actualValue')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.customer"/>:</td>

                <td valign="top" class="value"><g:link controller="customer" action="show" id="${jobInstance?.customer?.id}">${jobInstance?.customer?.encodeAsHTML()}</g:link></td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.date"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'date')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.discount"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'discount')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.jobs"/>:</td>

                <td valign="top" style="text-align:left;" class="value">
                    <ul>
                        <g:each var="j" in="${jobInstance.jobItems}">
                            <li><g:link controller="jobItem" action="show" id="${j.id}">${j?.encodeAsHTML()}</g:link></li>
                        </g:each>
                    </ul>
                    <g:if test="${(jobInstance?.status == Constants.JOB_STATUS_CREATED || AuthorizeTools.ifAnyGranted('ROLE_ADMIN'))}">
                        <g:link controller="jobItem" params="['job.id':jobInstance?.id]" action="create"><g:message code="job.link.add.jobitem"/></g:link>
                    </g:if>
                </td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.status"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'status')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.original.value"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'originalValue')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.value"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'value')}</td>

            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="job.table.point"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: jobInstance, field: 'point')}</td>

            </tr>

            </tbody>
        </table>
    </div>
    <div class="buttons">
        <g:form>
            <input type="hidden" name="id" value="${jobInstance?.id}"/>
            <span class="button"><g:actionSubmit class="edit" value="${message(code: 'common.button.edit')}" action="edit"/></span>
            <g:if test="${((jobInstance?.printable && AuthorizeTools.ifAnyGranted(Constants.ROLE_SHOP_ASSISTANT)) || AuthorizeTools.ifAnyGranted(Constants.ROLE_MANAGER) || AuthorizeTools.ifAnyGranted(Constants.ROLE_ADMIN))}">
                <span class="button"><g:render template="printReciptButton" model="[id:jobInstance.id]"/></span>
            </g:if>
            <span class="button"><g:actionSubmit class="delete" onclick="return confirm('${message(code:'common.delete.confirm')}');" value="Delete"/></span>
        </g:form>
    </div>
</div>
</body>
</html>
